Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error reporting when source cannot be minimized #16

Merged
merged 2 commits into from
Apr 21, 2024

Conversation

AlexWaygood
Copy link
Contributor

I ran into this ValueError while working on https://github.com/astral-sh/ruff/blob/main/scripts/fuzz-parser/fuzz.py, and found it slightly confusing at first. The issue we were running into was that a race condition (from running many fuzzing processes in parallel in a ProcessPoolExecutor) was meaning that our contains_bug() function was flaky -- so pysource-codegen would report that there was a bug, but then pysource-minimize wouldn't be able to repro the bug, causing the ValueError to be raised. But the exception message made me think that ruff's parser was erroring out because of some odd whitespace or other trivia that would be erased from the ast.parse()/ast.unparse() roundtrip, and that wasn't the case.

This PR attempts to improve the error message here slightly. It also adds a dedicated exception class, so that I can do except CouldNotMinimize here instead of except ValueError (which feels not great, since a lot of things could raise ValueError; it's hard to know that the ValueError is coming from pysource-minimize specifically there :-)

@15r10nk
Copy link
Owner

15r10nk commented Apr 21, 2024

Uhh, you actually found another problem without knowing it. pysource-minimize should be able to minimize flaky bugs. That is actually what the retry option is for. I will look into it next week

@15r10nk 15r10nk mentioned this pull request Apr 21, 2024
@15r10nk 15r10nk merged commit 3f76b9d into 15r10nk:main Apr 21, 2024
11 checks passed
@AlexWaygood AlexWaygood deleted the improve-error-reporting branch April 21, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants